import os
from multiprocessing import Process, Manager
import numpy as np
import signal
import time
from itertools import product
import subprocess

# parameter analysis for SAGloss

import tool

# # step 1
# r_e_list = [1.0]
# r_p_list = [0.1, 0.5, 0.6, 1.0, 2.5, 10, 100]
# enlarge_list = [1.1, 1.6, 2, 10]
# perplexity_list = [20, 50, 100, 300, 500]
# embdim_list = [100, 200, 400]
# v_list = [0.003, 0.009, 0.01, 0.05]

# # step 2
# r_e_list = [1.0]
# r_p_list = [0.5, 0.6, 0.7, 0.8, 0.9]
# enlarge_list = [1.1, 2, 10]
# perplexity_list = [50, 100, 300]
# embdim_list = [100, 200, 400]
# v_list = [0.001,0.002, 0.003, 0.004, 0.005]

# # step 3
# r_e_list = [1.0]
# r_p_list = [0.7, 0.8, 0.9]
# enlarge_list = [1.1, 2, 10, 100]
# perplexity_list = [40,  60,  80,]
# embdim_list = [100, 200, 400]
# v_list = [0.001, 0.0015, 0.002, 0.0025, 0.0035]
# dropedgerate_list = [0.00, 0.001, 0.01, 0.05, 0.1]

# step 1
r_e_list = [1.0]
r_p_list = [0.01, 0.1, 1, 10]
enlarge_list = [50]
perplexity_list = [10, 50, 100,]
embdim_list = [50, 100, 200]
v_list = [0.001, 0.002, 0.005,]
dropedgerate_list = [0, 0.001, 0.005, 0.01]
batch_size_list = [2708]

# step 2
r_e_list = [1.0]
r_p_list = [0.5, 1, 5]
enlarge_list = [10, 50]
perplexity_list = [30, 50, 80, 100,]
embdim_list = [200, 300, 500]
v_list = [0.0005, 0.001, 0.0015, 0.002]
dropedgerate_list = [0, 0.001, 0.005, 0.01]
batch_size_list = [2708]

# step 2
r_e_list = [1.0]
r_p_list = [0.9, 0.095, 1.0, 1.05, 1.1]
enlarge_list = [10, 30, 50]
perplexity_list = [30, 50, 80, 100,]
embdim_list = [200]
v_list = [0.00125, 0.0015, 0.00175, 0.002]
dropedgerate_list = [0, 0.001, 0.005]
batch_size_list = [2708]

# step 2
r_e_list = [1.0]
r_p_list = [ 0.95, 1.0]
enlarge_list = [10, 30, 50]
perplexity_list = [50,60,70,80]
embdim_list = [200]
v_list = [0.0012, 0.0013, 0.0014, 0.0015,]
dropedgerate_list = [0, 0.001, 0.005, 0.01]
batch_size_list = [2708]

cudalist = [
    # 3,
    # 0,
    # 1,
    # 0,
    1,
    2,
    3,
    4,
    5,
    6,
    7,
]

changeList = [batch_size_list, v_list,dropedgerate_list, embdim_list, perplexity_list, enlarge_list, r_e_list, r_p_list]
paramName = ['batch_size','v', 'dropedgerate', 'embdim', 'perplexity', 'enlarge', "r_e", "r_p", ]
mainFunc = "./main_graph_Cora.py"
ater = tool.AutoTrainer(
    changeList,
    paramName,
    mainFunc,
    deviceList=cudalist,
    poolNumber=2*len(cudalist),
    name="autotrain",
    waittime=1,
)
ater.Run()
